import { requestClient } from '#/api/request';

export namespace CmtCourseCategoryApi {
  /** 课程分类 */
  export interface CourseCategory {
    id?: number;
    communityId?: number;
    merchantId?: number;
    name?: string;
    icon?: string;
    sort?: number;
    createTime?: string;
  }

  /** 课程分类分页查询参数 */
  export interface CourseCategoryPageReqVO {
    pageNo: number;
    pageSize: number;
    communityId?: number;
    merchantId?: number;
    name?: string;
    createTime?: string[];
  }
}

/** 查询课程分类分页 */
export function getCourseCategoryPage(params: CmtCourseCategoryApi.CourseCategoryPageReqVO) {
  return requestClient.get<any>('/cmt/course-category/page', { params });
}

/** 查询课程分类详情 */
export function getCourseCategory(id: number) {
  return requestClient.get<CmtCourseCategoryApi.CourseCategory>('/cmt/course-category/get', {
    params: { id },
  });
}

/** 新增课程分类 */
export function createCourseCategory(data: CmtCourseCategoryApi.CourseCategory) {
  return requestClient.post<number>('/cmt/course-category/create', data);
}

/** 修改课程分类 */
export function updateCourseCategory(data: CmtCourseCategoryApi.CourseCategory) {
  return requestClient.put<boolean>('/cmt/course-category/update', data);
}

/** 删除课程分类 */
export function deleteCourseCategory(id: number) {
  return requestClient.delete<boolean>('/cmt/course-category/delete?id=' + id);
}

/** 批量删除课程分类 */
export function deleteCourseCategoryList(ids: number[]) {
  return requestClient.delete<boolean>(
    '/cmt/course-category/delete-list?ids=' + ids.join(','),
  );
}

/** 导出课程分类 Excel */
export function exportCourseCategory(params: CmtCourseCategoryApi.CourseCategoryPageReqVO) {
  return requestClient.get<Blob>('/cmt/course-category/export-excel', {
    params,
    responseType: 'blob',
  });
}

/** 获取课程分类选项列表(用于下拉选择) */
export function getCourseCategoryOptions() {
  return requestClient.get<any>('/cmt/course-category/page', {
    params: { pageNo: -1, pageSize: 10 },
  });
}
